[XEN] Fix i386 hypercall code to always create shadow
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 28 Sep 2006 10:47:33 +0000 (11:47 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 28 Sep 2006 10:47:33 +0000 (11:47 +0100)
parameters. Arguments on stack can be clobbered by
callee, since it owns them. But we require this doesn't
happen when we create hypercall continuations. Hence the
need to copy.
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/x86_32/entry.S

index 06a25fa188bc684dab730f814d1dbedf790f215b..7ec820c7b555ba52602dc2faf4ff9e27fc275acb 100644 (file)
@@ -175,7 +175,7 @@ ENTRY(hypercall)
         jae   bad_hypercall
         PERFC_INCR(PERFC_hypercalls, %eax)
 #ifndef NDEBUG
-        /* Deliberately corrupt parameter regs not used by this hypercall. */
+        /* Create shadow parameters and corrupt those not used by this call. */
         pushl %eax
         pushl UREGS_eip+4(%esp)
         pushl 28(%esp) # EBP
@@ -192,11 +192,23 @@ ENTRY(hypercall)
         movl  $0xDEADBEEF,%eax
         rep   stosl
         movl  %esi,%eax
+#else
+        /* 
+         * We need shadow parameters even on non-debug builds. We depend on the
+         * original versions not being clobbered (needed to create a hypercall
+         * continuation). But that isn't guaranteed by the function-call ABI.
+         */ 
+        pushl 20(%esp) # EBP
+        pushl 20(%esp) # EDI
+        pushl 20(%esp) # ESI
+        pushl 20(%esp) # EDX
+        pushl 20(%esp) # ECX
+        pushl 20(%esp) # EBX
 #endif
         call *hypercall_table(,%eax,4)
+        addl  $24,%esp     # Discard the shadow parameters
 #ifndef NDEBUG
-        /* Deliberately corrupt parameter regs used by this hypercall. */
-        addl  $24,%esp     # Shadow parameters
+        /* Deliberately corrupt real parameter regs used by this hypercall. */
         popl  %ecx         # Shadow EIP
         cmpl  %ecx,UREGS_eip+4(%esp)
         popl  %ecx         # Shadow hypercall index